﻿namespace pptpclient
{
    using System;
    using System.Configuration;
    using System.Globalization;
    using System.Threading;
    using System.Windows;

    internal class Program : Application
    {
        public static Mutex mutex;

        private static bool InstanceExists()
        {
            bool flag;
            mutex = new Mutex(false, "My_Mutex_PPTP_DIAL_2010", out flag);
            return !flag;
        }

        [STAThread]
        private static void Main(string[] args)
        {
            if (InstanceExists())
            {
                string str = ConfigurationManager.OpenExeConfiguration(0).AppSettings.Settings["Language"].Value;
                if (string.IsNullOrEmpty(str))
                {
                    str = (CultureInfo.CurrentCulture.Name == "ru-RU") ? "ru" : "en";
                }
                if (str == "ru")
                {
                    MessageBox.Show("Вторую копию программы запускать нельзя", "Ошибка Мастера", MessageBoxButton.OK, MessageBoxImage.Hand);
                }
                if (str == "en")
                {
                    MessageBox.Show("You can not run a program twice", "Wizard Error", MessageBoxButton.OK, MessageBoxImage.Hand);
                }
            }
            else
            {
                new Application().Run(new MainWindow());
            }
        }
    }
}

